#include "rename.h"

Rename::Rename()
{
}

Rename::~Rename()
{
}

void Rename::init(QString *dir, QStringList *orig, QStringList *newname, int offset, int operations)
{
    qspDir = dir;
    qslpOrig = orig;
    qslpNew = newname;
    this->offset = offset;
    ops = operations;
}

void Rename::run()
{
    int errors=0;

    for(int i=offset; i<(offset+ops); i++)
    {   if(QString::compare(qslpOrig->at(i),qslpNew->at(i))==0)
            continue;

        QString qsOld((*qspDir)+"/"+qslpOrig->at(i));
        QString qsNew((*qspDir)+"/"+qslpNew->at(i));

        errors -= rename(qsOld.toAscii().data(),qsNew.toAscii().data());
    }
    emit completed(errors);
}
